home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / HYPOT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  447 b   |  23 lines

  1. /* hypot.c function, from page 216 of turboc bible */
  2. #include<math.h>
  3. #include<stdio.h>
  4. #include<stdlib.h>            /* errno is defined here */
  5. main(int argc, char **argv)
  6. {
  7.     double x, y, result;
  8.     if(argc < 3)
  9.     {
  10.         printf("Usage:%s <x> <y>\n", argv[0]);
  11.     }
  12.     else
  13.     {
  14.         x = atof(argv[1]);
  15.         y = atof(argv[2]);
  16.         result = hypot(x, y);
  17.         if(errno != ERANGE)
  18.         {
  19.             printf("hypot(%s, %s) = %f\n",
  20.             argv[1], argv[2], result);
  21.         }
  22.     }
  23. }